{% extends "site_base.html" %}

{% load i18n %}
{% load uni_form %}
{% load ifsetting_tag %}

{% block head_title %}{% trans "Login" %}{% endblock %}

{% block body %}
    
    {% if openid and not user.is_authenticated %}
        <p><span class="warning">It appears you have started to login using OpenID. Want to <a href="/openid/register/">finish logging in</a>?</span></p>
    {% endif %}
    
    <h1>{% trans "Log In" %}</h1>
    
    {% if user.is_authenticated %}
        <p><span class="warning">{% trans "Note" %}</span>: {% blocktrans %}you are already logged in as {{ user }}.{% endblocktrans %}</p>
    {% else %}
        {% ifsetting ACCOUNT_OPEN_SIGNUP %}
        {% url acct_signup as signup_url %}
        <p>{% blocktrans %}Don't have an account? <a href="{{ signup_url }}">Sign up</a>!{% endblocktrans %}</p>
        {% endifsetting %}
    {% endif %}
    
    <form class="login uniForm" method="POST" action="">
        <fieldset class="inlineLabels">
            <div class="form_block">
                <a href="{% url acct_passwd_reset %}">{% trans "Forgot password?" %}</a>
            </div>
            {{ form|as_uni_form }}
            <div class="form_block">
                <input type="submit" value="{% trans "Log in &raquo;" %}" />
            </div>
        </fieldset>
    </form>
    
    <p>{% trans "Or sign in with your OpenID" %}:</p>
    {# @@@ why isn't this just does as a form object ? #}
    <form class="login uniForm" action="/openid/register/" method="POST">
        <fieldset class="inlineLabels">
            {% if url_required %}
                <div class="ctrlHolder error">
                    <p class="errorField">
                        <strong>This field is required.</strong>
                    </p>
                    <label for="id_username">* OpenID Identifier</label>
                    <input class="openid" type="text" name="openid_url" />
                </div>
            {% else %}
                <div class="ctrlHolder">
                    <label for="id_username">* OpenID Identifier</label>
                    <input class="openid" type="text" name="openid_url" />
                </div>
            {% endif %}
            <div class="form_block">
                <input type="submit" value="{% trans "Log in &raquo;" %}" />
            </div>
        </fieldset>
    </form>
    
    <p>{% blocktrans %}If you have any trouble logging in to your account, contact us at <a href="mailto:{{ CONTACT_EMAIL }}">{{ CONTACT_EMAIL }}</a>.{% endblocktrans %}</p>
{% endblock %}

{% block extra_body %}
<script>
    $("#id_username").focus();
</script>
{% endblock %}